# -*- codeing = utf-8 -*-
# @Time : 2021/2/26 19:23
# @Atuthor: 朱朱
# @File: 121面向对象相关的方法.py
# @Software: PyCharm

class Person(object):
    def __init__(self, name, age):
        self.name = name
        self.age = age

class X(object):
    pass

class Student(Person,X):
    pass

p1 = Person('jack',18)
p2 = Person('jack',18)

s = Student('tom',20)

print(id(p1))
print(id(p2))
print(p1 is p2) # False is 比较的是内存地址

print(type(p1) == Person) # True 获取类对象
print(type(s) == Student) # True
print(type(s) == Person) # False

# isinstance 判断一个对象是否由指定的类(或父类)实例化出来的
print(isinstance(s, (Student, X))) # true
print(isinstance(s, (Student, ))) # true
print(isinstance(p1, Student)) # false
print(isinstance(p1, Person)) # true

# issubclass 判断一个类,是否是另一个类的子类
print(issubclass(Student, (Person, X))) # true
print(issubclass(Person, Student)) #false